import request from "@/utils/request";

// 空间树查询
export function getSpaceListTree(data) {
  return request({
    url: "/api/logistics/BasSpace/getListTree",
    method: "GET",
    data,
  });
}

// 获取子级树形数据
export function getChildSpaceListTree(data) {
  return request({
    url: "/api/logistics/BasSpace/getChildListTree",
    method: "GET",
    data,
  });
}

// 根据部门获取空间及父级空间列表
export function getSpaceAndParentListByOrg(data) {
  return request({
    url: "/api/logistics/BasSpace/getSpaceAndParentListByOrg",
    method: "GET",
    data,
  });
}

// 空间查询
export function getList(data) {
  return request({
    url: "/api/logistics/BasSpace/getList",
    method: "POST",
    data,
  });
}

// 删除空间
export const delSpace = (id) => {
  return request({
    url: `/api/logistics/BasSpace/${id}`,
    method: "DELETE",
  });
};

// 新建空间
export const createSpace = (data) => {
  return request({
    url: "/api/logistics/BasSpace",
    method: "POST",
    data,
  });
};

// 获取登录人所在空间
export const getUserSpace = () => {
  return request({
    url: "/api/logistics/BasSpace/getUserSpace",
    method: "POST",
  });
};

// 修改空间
export const updateSpace = (data) => {
  return request({
    url: `/api/logistics/BasSpace/${data.id}`,
    method: "PUT",
    data,
  });
};

// 修改空间
export const getSpace = (data) => {
  return request({
    url: `/api/logistics/BasSpace/${data}`,
    method: "GET",
    data,
  });
};
